package com.iteaj.iot.client;

import com.iteaj.network.IotProtocolFactory;
import com.iteaj.network.client.ClientMessage;
import org.springframework.core.GenericTypeResolver;

public abstract class SimpleTcpClientComponent<T extends ClientMessage> extends TcpClientComponent implements IotProtocolFactory<T> {

    @Override
    public Class<? extends ClientMessage> messageClass() {
        Class<?> aClass = GenericTypeResolver.resolveTypeArgument(getClass()
                , SimpleTcpClientComponent.class);
        return (Class<T>) aClass;
    }

    @Override
    public abstract TcpRequestProtocol getProtocol(T message);
}
